//根据身份证号获取生日
export function getBirth(idCard) {
  var birthday = ''
  if (idCard != null && idCard != '') {
    if (idCard.length == 15) {
      birthday = '19' + idCard.slice(6, 12)
    } else if (idCard.length == 18) {
      birthday = idCard.slice(6, 14)
    }
    birthday = birthday.replace(/(.{4})(.{2})/, '$1-$2-')
    //通过正则表达式来指定输出格式为:1990-01-01
  }
  return birthday
}

//根据身份证号获取性别
export function getSex(idCard) {
  var sexStr = ''
  if (parseInt(idCard.substr(16, 1)) % 2 == 1) {
    sexStr = 'M' //男
  } else {
    sexStr = 'F' //
  }
  return sexStr
}
